package com.yyfax.demo.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yyfax.demo.bean.Transfer;
import com.yyfax.demo.common.util.SnowflakeIdUtil;
import com.yyfax.demo.dao.TransferDao;
import com.yyfax.demo.dao.TransferFuyouDao;
import com.yyfax.demo.service.TransferService;


/**
 * 
 * TODO(这里用一句话描述这个类或接口的作用)
 * @author lixin
 * @date 2018-05-03 08:56:48
 * @since TODO(说明当前修改版本号)
 */
@Service
public class TransferServiceImpl implements TransferService {

	@Autowired
	private TransferDao transferDao;
	
	@Autowired
	private TransferFuyouDao transferFuyouDao;

	@Override
	public void batchInsert() {
		// TODO Auto-generated method stub
		
		List list = new ArrayList();
		
		List fuuyouList = new ArrayList();
		
		for (int i=0 ; i< 1000000;i++) {
	
			Transfer transfer = new Transfer();
			long id = SnowflakeIdUtil.generate();
			transfer.setId(id);
			transfer.setAmount(689.26);
			transfer.setBusId(id);
			transfer.setPayId(id);
			list.add(transfer);
			fuuyouList.add(transfer);
			if(list.size() == 2000) {
				transferDao.batchInsertTransfer(list);
				transferFuyouDao.batchInsertTransfer(fuuyouList);
				list = new ArrayList();
				fuuyouList = new ArrayList();
			}
		}
	}

	
	
	
}
